package com.example.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.ExamRecord;

@Mapper
public interface ExamRecordMapper extends BaseMapper<ExamRecord> {
    
    @Select("SELECT * FROM exam_records WHERE exam_id = #{examId}")
    List<ExamRecord> findByExamId(@Param("examId") Long examId);
    
    @Select("SELECT * FROM exam_records WHERE student_id = #{studentId}")
    List<ExamRecord> findByStudentId(@Param("studentId") Long studentId);
    
    @Select("SELECT * FROM exam_records WHERE class_id = #{classId}")
    List<ExamRecord> findByClassId(@Param("classId") Long classId);
    
    @Select("SELECT * FROM exam_records WHERE exam_id = #{examId} AND student_id = #{studentId}")
    ExamRecord findByExamIdAndStudentId(@Param("examId") Long examId, @Param("studentId") Long studentId);
    
    @Select("SELECT * FROM exam_records WHERE exam_id = #{examId} AND class_id = #{classId}")
    List<ExamRecord> findByExamIdAndClassId(@Param("examId") Long examId, @Param("classId") Long classId);

    /**
     * 根据考试ID获取所有考试记录
     */
    @Select("SELECT * FROM exam_records WHERE exam_id = #{examId}")
    List<ExamRecord> selectByExamId(@Param("examId") Long examId);
} 